package org.execute.tool.使用.提取Excel中两列对比;



import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;

public class Functioning {
    public static void main(String[] args) {
        String excelFilePath_0 = "E:\\Downloads\\内容2025年2月27日19_21_28.xlsx";
        String sheetName_0 = "Sheet1";// 假设你要提取的表单名为Sheet1

        String excelFilePath_1 = "E:\\Downloads\\名字2025年2月27日192147.xlsx";
        String sheetName_1 = "Sheet1";// 假设你要提取的表单名为Sheet1

        int[] columnIndices_0 = {0, 1}; // 假设你要提取第一、第二和第三列
        int[] columnIndices_1 = {0, 1}; // 假设你要提取第一、第二和第三列

        Map<Integer, List<String>> columnDataMap_0 = ExcelColumnExtractor.extractColumnFromExcel(excelFilePath_0, sheetName_0, columnIndices_0);
        List<String> strings0_key = columnDataMap_0.get(columnIndices_0[0]);
        List<String> strings0_value = columnDataMap_0.get(columnIndices_0[1]);
        ArrayList<DataObject> dataObjects_0 = new ArrayList<>();
        for (int i = 0; i < strings0_key.size(); i++) {
            if (i>strings0_value.size()) {
                dataObjects_0.add(new DataObject(strings0_key.get(i),null));
            }else{
                dataObjects_0.add(new DataObject(strings0_key.get(i),strings0_value.get(i)));
            }

        }
        Map<Integer, List<String>> columnDataMap_1 = ExcelColumnExtractor.extractColumnFromExcel(excelFilePath_1, sheetName_1, columnIndices_1);
        List<String> strings1_key = columnDataMap_1.get(columnIndices_1[0]);
        List<String> strings1_value = columnDataMap_1.get(columnIndices_1[1]);
        ArrayList<DataObject> dataObjects_1 = new ArrayList<>();
        for (int i = 0; i < strings1_key.size(); i++) {
            if (i>strings1_value.size()) {
                dataObjects_1.add(new DataObject(strings1_key.get(i),null));
            }else{
                dataObjects_1.add(new DataObject(strings1_key.get(i),strings1_value.get(i)));
            }

        }


        List<DataObject> dataObjects = ListComparison.listComparison(dataObjects_0, dataObjects_1);
        // 使用 for-each 循环遍历 map
        for (DataObject dataObject : dataObjects) {
            System.out.println(dataObject.getKey() + " : " + dataObject.getValue());
        }
    }

}
